/* GUI CONVERTED from rscadj.p (converter v1.75) Fri May 18 04:06:51 2001 */
/* rscadj.p - Release Management Supplier Schedules - CUM RECEIVE ADJUST */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                   */
/* All rights reserved worldwide.  This is an unpublished work.          */
/* $Revision: 1.8.1.3 $                                                      */
/*V8:ConvertMode=Maintenance                                             */
/* REVISION: 7.3    LAST MODIFIED: 10/09/92           BY: WUG *G462*     */
/* REVISION: 7.3    LAST MODIFIED: 05/07/93           BY: WUG *GA82*     */
/* REVISION: 7.3    LAST MODIFIED: 10/18/93           BY: WUG *GG36*     */
/* REVISION: 7.3    LAST MODIFIED: 11/01/94           BY: ame *GN88*     */
/* REVISION: 8.5    LAST MODIFIED: 12/13/94           BY: MWD *J034*     */
/* REVISION: 7.4    LAST MODIFIED: 04/25/95           BY: dpm *J044*     */
/* REVISION: 8.5    LAST MODIFIED: 06/07/96   BY: *J0QS* M. Deleeuw      */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane       */
/* REVISION: 8.6E   LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan      */
/* REVISION: 8.6E   LAST MODIFIED: 08/17/98   BY: *L062* Steve Nugent    */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan      */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00   BY: *N0KP* myb             */
/* Old ECO marker removed, but no ECO header exists *F0PN*               */
/* $Revision: 1.8.1.3 $    BY: Kaustubh K.    DATE: 05/16/01 ECO: *M17N*      */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* CUM RECEIVE ADJUST */

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rscadj_p_1 "Remarks"
/* MaxLen: Comment: */

&SCOPED-DEFINE rscadj_p_2 "Cum Shipped Start Date"
/* MaxLen: Comment: */

&SCOPED-DEFINE rscadj_p_3 "Cum Received"
/* MaxLen: Comment: */

&SCOPED-DEFINE rscadj_p_4 "Adjust or Reset (A/R)"
/* MaxLen: Comment: */

&SCOPED-DEFINE rscadj_p_5 "A/R"
/* MaxLen: Comment: */

&SCOPED-DEFINE rscadj_p_6 "Subcontract Type"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable adj_type  like mfc_logical format {&rscadj_p_5}
                          label {&rscadj_p_4} initial yes.
define variable Remarks   as character format "x(24)" label {&rscadj_p_1}.
define variable adjust    as logical initial yes.
define variable reset     as logical initial no.
define variable scx_recid as recid.
define variable pod_recid as recid.
define variable tr_recid  as recid.
define variable last_cum_qty as decimal.
define variable impexp    like mfc_logical no-undo.
define variable subtype   as character format "x(12)"
                          label {&rscadj_p_6} no-undo.
define variable l_old_db     like si_db   no-undo.
define variable l_error-flag as   integer no-undo.

{rsordfrm.i}

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
adj_type             colon 30
   Remarks              colon 30
   skip(1)
   pod_cum_qty[1]       colon 30 label {&rscadj_p_3}
   skip(1)
   pod_cum_date[1]      colon 30 label {&rscadj_p_2}
 SKIP(.4)  /*GUI*/
with frame b width 80 attr-space side-labels NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:HIDDEN in frame b = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame b:handle).

mainloop:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

    /* THE SITE CHECK IS IN RSGETORD.I */
   {rsgetord.i "old"  " "  " " "validate"}

   pod_recid = recid(pod_det).
   find pod_det where recid(pod_det) = pod_recid exclusive-lock.
   find po_mstr where po_nbr = pod_nbr no-lock.

   do with frame b:
      display
         pod_cum_qty[1]
         pod_cum_date[1].

      last_cum_qty = pod_cum_qty[1].

      update adj_type Remarks.

      if adj_type = adjust then
         update
            pod_cum_qty[1].
      else do:
         assign pod_cum_qty[1] = 0.
         display pod_cum_qty[1].
      end.

      update pod_cum_date[1].

      for first si_mstr
         fields (si_db si_desc si_site)
         where si_site = po_site no-lock:
      end. /* FOR FIRST si_mstr */
      if available si_mstr
         or po_site = ""
      then do:
         l_old_db = global_db.
         if pod_po_db <> global_db
         then do:
            {gprun.i ""gpalias3.p"" "(input pod_po_db,
                                      output l_error-flag)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end. /* IF pod_po_db <> global_db */
         {gprun.i ""rscadj1.p"" "(input pod_nbr,
                                  input pod_line,
                                  input pod_cum_qty[1])"}
/*GUI*/ if global-beam-me-up then undo, leave.

         if global_db <> l_old_db
         then do:
            {gprun.i ""gpalias3.p"" "(input l_old_db,
                                      output l_error-flag)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end. /* IF global_db <> l_old_db */
      end. /* IF AVAILABLE si_mstr */
      else do:
         /* SITE # DOES NOT EXIST FOR # DB */
         {pxmsg.i &MSGNUM=4649
                  &ERRORLEVEL=4
                  &MSGARG1=po_site
                  &MSGARG2=pod_po_db}
         undo mainloop, retry mainloop.
      end. /* ELSE DO */

      create tr_hist.
      assign
         tr_date      = today
         tr_effdate   = today
         tr_part      = pod_part
         tr_type      = if adj_type = adjust
                        then
                           "CUM-RADJ"
                        else
                           "CUM-RRES"
         tr_nbr       = pod_nbr
         tr_line      = pod_line
         tr_addr      = po_vend
         tr_program   = execname
         tr_time      = time
         tr_loc_begin = pod_cum_qty[1]
         tr_rmks      = Remarks
         tr_userid    = global_userid
         tr_qty_chg   = pod_cum_qty[1] - last_cum_qty
         tr_recid     = recid(tr_hist).
      if recid(tr_hist) = -1 then .

      {mfntran.i}

      {gprun.i ""rsmrw.p"" "(input pod_nbr, input pod_line, input no)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      display
         pod_cum_qty[1]
         pod_cum_date[1].
   end.
/*GUI*/ if global-beam-me-up then undo, leave.

end. /* MAINLOOP */
